Skip to content

Faithful surface: control-WebSocket exec + real checkpoint NDJSON API (v0.3.0) - #7

Merged
lex00 merged 1 commit into
mainfrom
feat/faithful-ws-exec-v0.3.0
Jul 12, 2026
Merged

Faithful surface: control-WebSocket exec + real checkpoint NDJSON API (v0.3.0)#7
lex00 merged 1 commit into
mainfrom
feat/faithful-ws-exec-v0.3.0

Conversation

@lex00

@lex00 lex00 commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Aligns spritzer to the real Sprites API, reverse-engineered from superfly/sprites-go (websocket.go, checkpoint.go) with a live-token smoke test. Supersedes the docs-based v0.2.0 guess.

Exec is a control WebSocket

GET /v1/sprites/{name}/exec upgrades to WS. Command via repeated cmd query params (+ path). Non-PTY binary framing [StreamID][payload]: stdin=0, stdout=1, stderr=2, exit=3 (payload[0]=exit code), stdinEOF=4. Matches the SDK's wire protocol, so a chant WS client gets a real exit code (the compensation trigger).

Real checkpoint API

  • Create POST /v1/sprites/{name}/checkpoint (singular) {comment?} → streaming NDJSON (infocomplete {id:"v1"}). Plural POST is now 405, as real Sprites returns.
  • List GET .../checkpoints → bare array [{id, comment, create_time, is_auto}].
  • Get GET .../checkpoints/{id}; Restore POST .../checkpoints/{id}/restore → NDJSON.

Verify

build/vet/gofmt/test/-race + golangci-lint v2.12.2 all green. Live smoke: WS echo hi → frames 01 68 69 0a (stdout "hi\n") + 03 00 (exit 0); ./risky.sh02 … stderr + 03 01 (exit 1). Checkpoint loop: singular create NDJSON → array list → restore NDJSON.

Cuts as v0.3.0. (github.com/coder/websocket added.)

🤖 Generated with Claude Code

Aligns exec and checkpoints with the real Sprites API surface
reverse-engineered from superfly/sprites-go (websocket.go, checkpoint.go).

Exec moves from JSON POST to a control WebSocket at GET
/v1/sprites/{id}/exec speaking the framed [streamID][payload] protocol
(StreamStdin=0, StreamStdout=1, StreamStderr=2, StreamExit=3,
StreamStdinEOF=4). The command is reconstructed from cmd/path query
params and run through the existing scripted interpreter; the server
writes stdout as [1], stderr as [2], then [3]<exitCodeByte> and closes.
The handshake advertises sprite-capabilities: control-ws.

Checkpoint create moves to the singular POST /v1/sprites/{id}/checkpoint
and streams NDJSON progress ending in {"event":"complete","id":"v<N>"}.
The list is now a bare JSON array of {id, comment, create_time, is_auto}
and a new GET .../checkpoints/{id} returns one checkpoint. Restore
streams NDJSON. Adds github.com/coder/websocket.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lex00
lex00 merged commit 13366ea into main Jul 12, 2026
2 checks passed
@lex00
lex00 deleted the feat/faithful-ws-exec-v0.3.0 branch July 12, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant